home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / messages / src / putmsg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  2.1 KB  |  93 lines

  1. /*
  2.     $Id$
  3.     $Log$
  4.     Desc:
  5.     Lang: english
  6. */
  7. #include "exec_intern.h"
  8. #include <exec/ports.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13.     #include <clib/exec_protos.h>
  14.  
  15.     __AROS_LH2(void, PutMsg,
  16.  
  17. /*  SYNOPSIS */
  18.     __AROS_LA(struct MsgPort *, port, A0),
  19.     __AROS_LA(struct Message *, message, A1),
  20.  
  21. /*  LOCATION */
  22.     struct ExecBase *, SysBase, 61, Exec)
  23.  
  24. /*  FUNCTION
  25.     Sends a message to a given message port. Messages are not copied
  26.     from one task to another but must lie in shared memory instead.
  27.     Therefore the owner of the message may generally not reuse it before
  28.     it is returned. But this depends on the two tasks sharing the message.
  29.  
  30.     INPUTS
  31.     port    - Pointer to messageport.
  32.     message - Pointer to message.
  33.  
  34.     RESULT
  35.  
  36.     NOTES
  37.     It is legal to send a message from within interrupts.
  38.  
  39.     Messages may either trigger a signal at the owner of the messageport
  40.     or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
  41.  
  42.     EXAMPLE
  43.  
  44.     BUGS
  45.  
  46.     SEE ALSO
  47.     WaitPort(), GetMsg()
  48.  
  49.     INTERNALS
  50.  
  51.     HISTORY
  52.     29-10-95    digulla automatically created from
  53.                 exec_lib.fd and clib/exec_protos.h
  54.     17-12-95    digulla Incorporated code by Matthias Fleischner
  55.  
  56. *****************************************************************************/
  57. {
  58.     __AROS_FUNC_INIT
  59.     /*
  60.     Messages may be sent from interrupts. Therefore the message list
  61.     of the message port must be protected with Disable().
  62.     */
  63.     Disable();
  64.  
  65.     /* Set the node type to NT_MESSAGE == sent message. */
  66.     message->mn_Node.ln_Type=NT_MESSAGE;
  67.  
  68.     /* Add it to the message list. */
  69.     AddTail(&port->mp_MsgList,&message->mn_Node);
  70.  
  71.     /* And trigger the action. */
  72.     switch(port->mp_Flags&PF_ACTION)
  73.     {
  74.     case PA_SIGNAL:
  75.         /* Send the signal */
  76.         Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
  77.         break;
  78.  
  79.     case PA_SOFTINT:
  80.         /* Raise a software interrupt */
  81.         Cause((struct Interrupt *)port->mp_SoftInt);
  82.         break;
  83.  
  84.     case PA_IGNORE:
  85.         /* Do nothing. */
  86.         break;
  87.     }
  88.  
  89.     /* All done. */
  90.     Enable();
  91.     __AROS_FUNC_EXIT
  92. } /* PutMsg */
  93.